package com.blog.controller;

import com.blog.entity.Blogger;
import com.blog.service.BloggerService;
import com.blog.util.CryptographyUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class RegisterController {

    @Resource
    private BloggerService bloggerService;

    @RequestMapping("/register")
    public String register(@RequestParam("userName") String userName, @RequestParam("password")String password, @RequestParam("userNumber")String userNumber){
        Blogger blogger = new Blogger();
        blogger.setUserName(userName);
        blogger.setUserNumber(userNumber);
        blogger.setPassword(CryptographyUtil.md5(password, "SunBingRui"));
        bloggerService.addUser(blogger);
        return "redirect:/";
    }

}
